//
// Created by liushuai on 2020/1/31.
//
#include "rotate.h"
void rotate(vector<vector<int>>& matrix){
    int length = matrix.size();
    int span = length-1;
    int layers = length/2;
    int currentValue = 0;
    int nextValue = 0;
    for(int i=0;i<layers;i++){
        for(int j=i;j<span;j++){
            int headValue = matrix[i][j];

            currentValue = matrix[i][j];//--5
            nextValue = matrix[j][i+span];//--11
            matrix[j][i+span] = currentValue;//11==>5

            currentValue = nextValue;
            nextValue = matrix[i+span][i+span-j];//--16
            matrix[i+span][i+span-j] = currentValue;//16==>11

            currentValue = nextValue;//16
            nextValue = matrix[i+span-j][i];//
            matrix[i+span-j][i] = currentValue;//15==>16
            matrix[i][j] = nextValue;
        }
        span/=2;
    }



}
